// TTable.cpp

#include "includes.h"

TTable::TTable()
{
	memset(tTable, 0, sizeof(tTable)); //bzero is depricated, I had no idea

	printf("sizeof(tTable) = %i", sizeof(tTable));
}

void TTable::add(unsigned long long int inHash, unsigned int inA, unsigned int inB, 
		             int inValue, int inDepth)
{
	unsigned int index = 0xFFFFF & inHash; //lop the first 20 bits off
	
	tTable[index].hash = inHash;
	tTable[index].a = inA;
	tTable[index].b = inB;
	tTable[index].value = inValue;
	tTable[index].depth = inDepth;
	tTable[index].valid = true;
}

TTableEntry * TTable::get(unsigned long long int inHash)
{
	unsigned int index = 0xFFFFF & inHash; //lop the first 20 bits off
	if (!tTable[index].valid)
		return 0; //null pointer
	else if (tTable[index].hash != inHash)
		return 0; //null pointer
	else
		return &tTable[index];
}



